package com.cheetah.start.common.base.result;

import lombok.Data;

/**
 * @author Feel
 */
@Data
public class ResultTable<T> {

    /**
     * 代码
     */
    private Integer code;

    /**
     * 消息
     */
    private String msg;

    /**
     * 总量
     */
    private Long count;

    /**
     * 数据
     */
    private T data;

    /**
     * 构 建
     */
    public static <T> ResultTable<T> pageTable(long count, T data) {
        ResultTable<T> resultTable = new ResultTable<>();
        resultTable.setData(data);
        resultTable.setCode(ResultCode.SUCCESS.getCode());
        resultTable.setCount(count);
        return resultTable;
    }

    public static <T> ResultTable<T> pageTable(T data, long count) {
        return pageTable(count, data);
    }

    public static <T> ResultTable<T> dataTable(T data) {
        ResultTable<T> resultTable = new ResultTable<>();
        resultTable.setData(data);
        resultTable.setCode(0);
        return resultTable;
    }

}
